home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Game-Power
/
Amiga Game-Power.iso
/
pd mix ii
/
access
/
hddriver
/
support
/
interleave.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-20
|
2KB
|
80 lines
#include <stdio.h>
#include "hd.h"
APTR IntuitionBase;
extern APTR OpenLibrary ();
char buf[512];
main ()
{
int i;
long sec1,sec2, micro1,micro2;
struct posn posn;
int loop;
IntuitionBase = OpenLibrary ( "intuition.library" , 0L );
if ( IntuitionBase == NULL ) {
printf ( "Failed to open intuition.library\n" );
exit ( 1 );
}
if ( wd_open () == 0 ) {
posn.cylinder = 10;
posn.surface = 0;
for ( i = 0; i < first.sectors; i++ ) {
printf ( "Trying interleave %d\n" , i );
fflush ( stdout );
new_interleave ( i , first.sectors );
posn.sector = 0;
posn.block = posn.sector + ( posn.surface * first.sectors )
+ ( posn.cylinder * first.sectors * first.heads );
wd_format_track ( &posn );
CurrentTime ( &sec1 , µ1 );
for ( loop = 0; loop < 20; loop++ ) {
for ( posn.sector = 0; posn.sector < first.sectors; posn.sector++ ) {
posn.block = posn.sector
+ ( posn.surface * first.sectors )
+ ( posn.cylinder * first.sectors * first.heads );
read_sector ( &posn , buf );
}
}
CurrentTime ( &sec2 , µ2 );
sec2 -= sec1;
micro2 -= micro1;
if ( micro2 < 0 ) {
micro2 += 1000000;
sec2--;
}
printf ( "difference %ld sec, %ld micro\n" , sec2 , micro2 );
}
wd_close ();
}
else
printf ( "wd_reset() failed\n" );
CloseLibrary ( IntuitionBase );
}
new_interleave ( interleave )
int interleave;
{
int i;
int j;
for ( i = 0; i < first.sectors; i++ )
first.interleave[i*2+1] = first.sectors; /* mark as free */
j = 0;
for ( i = 0; i < first.sectors; i++ ) {
while ( first.interleave[j*2+1] != first.sectors ) {
j++;
while ( j >= first.sectors ) j -= first.sectors;
}
first.interleave[j*2+1] = i;
j += interleave;
while ( j >= first.sectors ) j -= first.sectors;
}
for ( i = 0; i < first.sectors; i++ )
printf ( "%d " , first.interleave[i*2+1] );
printf ( "\n" );
}